﻿using Infrastructure.DomainEvent;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace Infrastructure.AggregateBase
{
    public abstract class AggregateRoot<T,TKey> : AggregateRoot where T : IEntity
    {
        public abstract TKey ID { get; set; }

        
    }

    public abstract class AggregateRoot : IEntity
    {
        public Guid Identity { get; set; } = Guid.NewGuid();
        public bool IsDelete { get; set; }

        protected List<DomainEventBase> _domainEvents = new List<DomainEventBase>();
        protected List<DomainEventBase> _domainAdminEvents = new List<DomainEventBase>();

        public virtual void AddDomainEvent(DomainEventBase domainEvent)
            => _domainEvents.Add(domainEvent);

        public virtual void RemoveDomainEvent(DomainEventBase domainEvent)
            => _domainEvents.Remove(domainEvent);

        public List<DomainEventBase> GetDomainEvents()
            => _domainEvents;


        public virtual void AddAdminDomainEvent(DomainEventBase domainEvent)
            => _domainAdminEvents.Add(domainEvent);

        public virtual void RemoveAdminDomainEvent(DomainEventBase domainEvent)
            => _domainAdminEvents.Remove(domainEvent);
        public List<DomainEventBase> GetAdminDomainEvents() 
            => _domainAdminEvents;
    }
}
